<?php
/**
 * This is a standalone page to save a file.  All globals/constants on the index.php
 * page should be declared here so that no errors occur.
 */
define("ROOTDIR", dirname(__FILE__)); // Global Constant of root directory

require_once(ROOTDIR."/config/class.Config.php");
$config = new Config(); // All configuration variables are contained in this object

include_once(ROOTDIR."/include/database/class.BanQueries.php");
require_once(ROOTDIR."/include/objects/class.Ip.php");

$filename = $config->siteName."_banned_ip.cfg";
$header = "Content-Disposition: attachment; filename=\"".$filename."\"";
header("Content-type: text/plain");
header($header);

$banQueries = new BanQueries();

$bannedIps = $banQueries->downloadActiveIps();

// Empty line after banid print is needed to force a new line
foreach($bannedIps as $bannedIp) {
?>
addip 0 <?=$bannedIp->getIp()?>

<?php
}
?>
